package it.unibo.imola.gui;

import org.eclipse.core.commands.AbstractHandler;
import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.core.commands.ExecutionException;
import org.eclipse.swt.widgets.Tree;
import org.eclipse.ui.PlatformUI;

public class ClearCommandHandler extends AbstractHandler {

	@Override
	public Object execute(ExecutionEvent event) throws ExecutionException {
		EditorView editorView = (EditorView) PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().findView(EditorView.ID);
		ConsoleView consoleView = (ConsoleView) PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().findView(ConsoleView.ID);
		TreeView treeView = (TreeView) PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().findView(TreeView.ID);		
		Tree tree = treeView.getTree();
		
		editorView.getStyledText().setText("");
		consoleView.getStyledText().setText("");
		tree.removeAll();
		return null;
	}

}
